home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / tblt / tblt⁄tablut.h < prev    next >
Encoding:
Text File  |  1986-01-03  |  4.8 KB  |  183 lines  |  [TEXT/MACA]

  1. /*
  2.  * tablut.h
  3.  */
  4.  
  5. #define MYSIGN    ((long) 'TBLT')    /* Tablut's signature    */
  6. #define MYFILE    ((long) 'TBTF')    /* game files' signature    */
  7.  
  8. #define WINDOWID 260        /* Resource ID of my window    */
  9.  
  10. /*
  11.  * screenport - used to keep the current port from ever dangling.
  12.  *   This is a port for the whole screen.
  13.  */
  14.  
  15. #ifndef DATA
  16. extern
  17. #endif
  18. GrafPtr screenport;
  19.  
  20. #ifndef DATA
  21. extern
  22. #endif
  23. WindowPtr mywindow;    /* Tablut's one window    */
  24.  
  25. struct piecebits {        /* per-piece-type image information    */
  26.     BitMap *data;        /* data to be Xor'ed        */
  27.     BitMap *mask;        /* bits to be cleared before drawing    */
  28.     Point etoc;        /* offset from edge to center of bitmap    */
  29. };
  30. #ifndef DATA
  31. extern
  32. #endif
  33. struct piecebits kingmaps;    /* maps for the Swedish King        */
  34. #ifndef DATA
  35. extern
  36. #endif
  37. struct piecebits muscmaps;    /* maps for a Muscovite        */
  38. #ifndef DATA
  39. extern
  40. #endif
  41. struct piecebits swedmaps;    /* maps for a Swede            */
  42.  
  43. #ifndef DATA
  44. extern
  45. #endif
  46. Rect boardrect;        /* rectangle enclosing the board.    */
  47.             /* ...used to see if a piece in on the board */
  48. #ifndef DATA
  49. extern
  50. #endif
  51. Point boardcenter;        /* window coords of the center of the board */
  52.  
  53. #ifndef DATA
  54. extern
  55. #endif
  56. Point squaredim;        /* offset from one square to the next    */
  57. #define SQUARESEP 1    /* width of the border between squares    */
  58.             /* ...(included in squaredim)        */
  59.  
  60. /*
  61.  * (*gridp)[][] - an array (centered at [0][0]) showing what squares are
  62.  * occupied by what pieces.  The +2 border is there so that code can
  63.  * blindly check for captures at [h-2] or [v-2] without running off the
  64.  * edge of the array.
  65.  */
  66. struct pieceimage *(*gridp)[2+9+2][2+9+2];
  67.  
  68. /*
  69.  * all pieces are stored in one array.  The following defines identify
  70.  * the pieces by their indices.
  71.  */
  72.  
  73. #define FIRSTSWEDE  0    /* index of the first swede piece    */
  74. #define LASTSWEDE   7    /* index of the last swede piece    */
  75. #define FIRSTMUSC   8    /* index of the first muscovite piece    */
  76. #define LASTMUSC   23    /* index of the last muscovite piece    */
  77. #define THEKING    24    /* index of the swedish king piece    */
  78. #define NUMPIECES  25    /* the total number of pieces        */
  79.  
  80. struct pieceimage {    /* per-piece image information    */
  81.     struct piecebits *class;    /* class of piece (e.g, a muscovite)    */
  82.     BitMap prevlook;    /* bits to restore on leaving this space */
  83.             /* NOTE: prevlook.bounds says where we are */
  84.     Point grid;        /* current grid coordinates of the piece */
  85.             /* ...or [NOGRID, NOGRID] if off-board    */
  86.     struct piecehome *curhome; /* valid only if on-screen but off-board */
  87.             /* ...points to the current home of the piece */
  88. };
  89. #ifndef DATA
  90. extern
  91. #endif
  92. struct pieceimage piece[NUMPIECES];    /* the pieces themselves    */
  93.  
  94. #define NOPLACE (-1000)    /* a coord where onscreen() is false    */
  95. #define NOGRID  (-100)    /* a grid coordinate for a piece that is */
  96.             /* ...off the board.        */
  97. #define onboard(p) ((p)->grid.h != NOGRID)
  98. #define onscreen(p) ((p)->prevlook.bounds.right >= 0)
  99.  
  100. struct piecehome {
  101.     Point hpoint;        /* home window coordinates        */
  102.     struct pieceimage *tenant; /* the piece currently at this home    */
  103. };
  104. #ifndef DATA
  105. extern
  106. #endif
  107. struct piecehome kinghome[1];    /* the swede king's home    */
  108. #ifndef DATA
  109. extern
  110. #endif
  111. struct piecehome swedhome[LASTSWEDE - FIRSTSWEDE + 1]; /* swedes' homes */
  112. #ifndef DATA
  113. extern
  114. #endif
  115. struct piecehome muschome[LASTMUSC - FIRSTMUSC + 1];   /* muscovites' homes */
  116. #ifndef DATA
  117. extern
  118. #endif
  119. struct piecehome weirdhome    /* used to catch illegal curhome references */
  120. #ifdef DATA
  121.  = {{10,10}, (struct pieceimage *) 0}
  122. #endif
  123. ;
  124.  
  125. #ifndef DATA    /*XXX should this go into draw.c alone?    XXX*/
  126. extern
  127. #endif
  128. GrafPtr flickport;        /* a temp port used to reduce flicker    */
  129.  
  130. #ifndef DATA
  131. extern
  132. #endif
  133. int insetup;        /* if true, almost any move is legal    */
  134.  
  135. #ifndef DATA
  136. extern
  137. #endif
  138. short curmove;        /* current move number (initial state == 0)  */
  139. #ifndef DATA
  140. extern
  141. #endif
  142. short nummoves;        /* number of moves in the game so far    */
  143.  
  144. #define blacksmove() ((curmove & 1) == 0)
  145.  
  146. #ifndef DATA
  147. extern
  148. #endif
  149. int winner;        /* who has won the game (if anyone)    */
  150. #define NOWIN    0    /* winner == NOWIN --> no winner yet    */
  151. #define WHITEWIN    1    /* white has won            */
  152. #define BLACKWIN    2    /* black has won            */
  153.  
  154. #define BOARDBYTES 21    /* # of bytes required to store the game state */
  155. #define BDPERBLK    10    /* # of game-states per memory chunk    */
  156.  
  157. struct moveblock {        /* one chunk of game-state memory    */
  158.     struct moveblock *nxtblk;
  159.     char bytes[BOARDBYTES * BDPERBLK];
  160. };
  161. #ifndef DATA
  162. extern
  163. #endif
  164. struct moveblock firstblock;    /* the first chunk of game-state memory */
  165.  
  166. #ifndef DATA
  167. extern
  168. #endif
  169. int ischanged;        /* "changes have been made but not stored" */
  170.  
  171. #ifndef DATA
  172. extern
  173. #endif
  174. char gamename[128];    /* (Pascal) name of the current game file    */
  175. #ifndef DATA
  176. extern
  177. #endif
  178. short gamevnum;        /* volume reference number for that file     */
  179. #ifndef DATA
  180. extern
  181. #endif
  182. short needsname;        /* "the game needs a new name"         */
  183.